if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_KhachHang_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_KhachHang_Update]
GO
CREATE PROC [sp_KhachHang_Update]
	@ID						INT,
	@Ten					NVARCHAR(50),
	@Ma_khu_vuc				INT,
	@Ma_nhom_khach_hang		INT,
	@Dia_chi				NVARCHAR(500),
	@Tel					NVARCHAR(40),
	@Fax					NVARCHAR(40),
	@Email					NVARCHAR(50),
	@So_tai_khoan			NVARCHAR(40),
	@Ngan_hang				NVARCHAR(40),
	@Ma_so_thue				varchar(40),
	@Ghi_chu				NVARCHAR(100)

AS
BEGIN
	DECLARE @Ngay_cap_nhat_cuoi datetime
	SET @Ngay_cap_nhat_cuoi = getdate()
	UPDATE KhachHang
		SET
					Ten = @Ten,
					Ma_khu_vuc = @Ma_khu_vuc,
					Ma_nhom_khach_hang = @Ma_nhom_khach_hang,
					Dia_chi = @Dia_chi,
					Tel = @Tel,
					Fax = @Fax,
					Email = @Email,
					So_tai_khoan = @So_tai_khoan,
					Ngan_hang = @Ngan_hang,
					Ma_so_thue = @Ma_so_thue,
					Ghi_chu = @Ghi_chu,
					Ngay_cap_nhat_cuoi = @Ngay_cap_nhat_cuoi
	WHERE 				
					id = @ID
END
